/*  1:   */ package com.atomikos.swing;
/*  2:   */ 
/*  3:   */ import java.io.File;
/*  4:   */ import java.util.Enumeration;
/*  5:   */ import java.util.Hashtable;
/*  6:   */ import javax.swing.filechooser.FileFilter;
/*  7:   */ 
/*  8:   */ public class ExtensionsFileFilter
/*  9:   */   extends FileFilter
/* 10:   */ {
/* 11:   */   private Hashtable extensions_;
/* 12:   */   
/* 13:   */   public static String getExtension(File f)
/* 14:   */   {
/* 15:43 */     String ext = null;
/* 16:44 */     String s = f.getName();
/* 17:45 */     int i = s.lastIndexOf('.');
/* 18:47 */     if ((i > 0) && (i < s.length() - 1)) {
/* 19:48 */       ext = s.substring(i + 1).toLowerCase();
/* 20:   */     }
/* 21:50 */     return ext;
/* 22:   */   }
/* 23:   */   
/* 24:   */   public ExtensionsFileFilter(String[] extensions)
/* 25:   */   {
/* 26:58 */     this.extensions_ = new Hashtable();
/* 27:59 */     for (int i = 0; i < extensions.length; i++) {
/* 28:60 */       this.extensions_.put(extensions[i].toLowerCase(), extensions[i].toLowerCase());
/* 29:   */     }
/* 30:   */   }
/* 31:   */   
/* 32:   */   public String getDescription()
/* 33:   */   {
/* 34:66 */     StringBuffer ret = new StringBuffer();
/* 35:67 */     Enumeration enumm = this.extensions_.keys();
/* 36:68 */     for (; enumm.hasMoreElements(); ret.append(" "))
/* 37:   */     {
/* 38:69 */       String nxt = (String)enumm.nextElement();
/* 39:70 */       ret.append(nxt);
/* 40:   */     }
/* 41:72 */     return ret.toString();
/* 42:   */   }
/* 43:   */   
/* 44:   */   public boolean accept(File f)
/* 45:   */   {
/* 46:77 */     boolean ret = false;
/* 47:78 */     if (f.isDirectory())
/* 48:   */     {
/* 49:79 */       ret = true;
/* 50:   */     }
/* 51:   */     else
/* 52:   */     {
/* 53:82 */       String extension = getExtension(f);
/* 54:83 */       if ((extension != null) && (this.extensions_.containsKey(extension))) {
/* 55:84 */         ret = true;
/* 56:   */       }
/* 57:   */     }
/* 58:87 */     return ret;
/* 59:   */   }
/* 60:   */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\atomikos-util\3.7.0\atomikos-util-3.7.0.jar
 * Qualified Name:     com.atomikos.swing.ExtensionsFileFilter
 * JD-Core Version:    0.7.0.1
 */